﻿package mortal.component.processbar
{
    import com.mui.controls.*;
    import com.mui.display.*;
    import mortal.common.*;
    import mortal.game.view.common.*;

    public class PointProcessBar extends GSprite
    {
        private var _bg:ScaleBitmap;
        private var _points:Array;
        private var _txt:GTextFiled;
        private var _pBgName:String;
        private var _pWidth:int;
        private var _pHeight:int;
        private var _maxNum:int;
        private var _curNum:int;

        public function PointProcessBar()
        {
            this._points = [];
            return;
        }// end function

        public function get textField() : GTextFiled
        {
            return this._txt;
        }// end function

        public function set label(param1:String) : void
        {
            this._txt.text = param1;
            return;
        }// end function

        public function setParams(param1:String, param2:String, param3:int, param4:int, param5:int) : void
        {
            this._pBgName = param2;
            DisplayUtil.removeMe(this._bg);
            this._bg = UIFactory.bg(0, 0, param3, param4, this, param1);
            this._pWidth = (param3 - 4) / param5;
            this._pHeight = param4 - 4;
            this._maxNum = param5;
            return;
        }// end function

        public function setProcess(param1:int) : void
        {
            this._curNum = param1;
            var _loc_2:int = 0;
            while (_loc_2 < this._curNum)
            {
                
                this.getPoint(_loc_2);
                _loc_2++;
            }
            DisplayUtil.delNotUse(this._points, _loc_2, true);
            this.updateLayout();
            return;
        }// end function

        public function updateLayout() : void
        {
            var _loc_1:int = 0;
            var _loc_2:ScaleBitmap = null;
            _loc_1 = 0;
            while (_loc_1 < this._points.length)
            {
                
                _loc_2 = this._points[_loc_1];
                _loc_2.y = 2;
                _loc_2.x = 2 + _loc_1 * (this._pWidth + 1);
                _loc_1++;
            }
            this._txt.x = this._bg.width + 2;
            this._txt.y = (this._bg.height - this._txt.height) / 2;
            return;
        }// end function

        private function getPoint(param1:int) : ScaleBitmap
        {
            var _loc_2:* = this._points[param1];
            if (_loc_2 == null)
            {
                _loc_2 = UIFactory.bg(0, 0, this._pWidth, this._pHeight, this, this._pBgName);
                pushUIToDisposeVec(_loc_2);
                this._points[param1] = _loc_2;
            }
            return _loc_2;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._txt = UIFactory.gTextField("", 0, 0, 100, 25, this);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            var _loc_2:ScaleBitmap = null;
            super.disposeImpl(param1);
            if (this._bg != null)
            {
                this._bg.dispose(param1);
                this._bg = null;
            }
            for each (_loc_2 in this._points)
            {
                
                _loc_2.dispose(param1);
            }
            this._txt.dispose(param1);
            this._txt = null;
            this._points = null;
            return;
        }// end function

    }
}
